package com.itany.conf;

import com.itany.intercepter.PermissionInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class TestMvcConfig implements WebMvcConfigurer {


    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/showlist").setViewName("userlist");
        registry.addViewController("/showManager").setViewName("manager");
        registry.addViewController("/showLogin").setViewName("login");
        registry.addViewController("/showIndex").setViewName("index");
        registry.addViewController("/showBookList").setViewName("booklist");
        registry.addViewController("/showSupplierExamine").setViewName("supplier_examine");
        registry.addViewController("/showSupplierPlatform").setViewName("supplier_platform");
        registry.addViewController("/showSupplierList").setViewName("supplierlist");
        registry.addViewController("/showSupplierBookList").setViewName("supplierbooklist");
        registry.addViewController("/showPermissions").setViewName("permission");
        registry.addViewController("/showRoles").setViewName("role");
        registry.addViewController("/showManagers").setViewName("manager");
//        registry.addViewController("/showOrderlist").setViewName("orderlist"); // 不做
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new PermissionInterceptor())
                .addPathPatterns("/show*")
                .addPathPatterns("/managerUser/login","/managerUser/logout");
    }
}
